/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package avenue;

import java.awt.Color;
import java.awt.Component;
import javax.swing.DefaultListCellRenderer;
import javax.swing.JList;
import model.VehicleColour;

/**
 *
 * @author Aggelos
 */
public class ColourRenderer extends DefaultListCellRenderer {

    @Override
    public Component getListCellRendererComponent(
            JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
        super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
        if (value instanceof VehicleColour) {
            VehicleColour mec = (VehicleColour) value;
            setText(mec.getName());
            
            /*list.setBackground(Color.decode(mec.getColorCode()));
            if (list.isSelectedIndex(-1)){
               list.setForeground(Color.white); 
                
            }*/
        }
        
        return this;
    }
}
